package com.khyr.controller;

import com.khyr.Service.ReturnPremiumService;
import com.khyr.entity.HisOrderBackfee;
import com.khyr.entity.HisOrderBackfeeItem;
import com.khyr.entity.HisOrderCharge;
import com.khyr.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.List;


/**
 * @author ：lyk
 * @date ：Created in 2025/3/13 20:25
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/charge/returnPremium")
public class ReturnPremiumController {
    @Autowired
    private ReturnPremiumService returnPremiumService;

    @GetMapping("/getChargedCareHistoryByRegId/{regId}")
    public R<GetChargedCareHistoryByRegIdReturnVo> getChargedCareHistoryByRegId(@PathVariable String regId) {
        GetChargedCareHistoryByRegIdReturnVo chargedCareHistoryByRegId = returnPremiumService.getChargedCareHistoryByRegId(regId);
        if (chargedCareHistoryByRegId == null){
            return new R<>(500,"查询失败",null);
        }
        return new R<>(200,"查询成功",chargedCareHistoryByRegId) ;
    }
    @PostMapping("/createOrderBackfeeWithCash")
    public R<String> createOrderBackfeeWithCash(@RequestBody OrderBackfeeVO orderBackfeeVO){
        return returnPremiumService.createOrderBackfeeWithCash(orderBackfeeVO);
    }
    @PostMapping("/queryAllOrderBackfeeForPage")
    public R<Page<HisOrderBackfee>> queryAllOrderBackfeeForPage(@RequestBody QueryParamsVo queryParamsVo){
        return returnPremiumService.queryAllOrderBackfeeForPage(queryParamsVo);
    }
    @GetMapping("/queryOrderBackfeeItemByBackId/{backId}")
    public R<List<HisOrderBackfeeItem>> queryOrderBackfeeItemByBackId(@PathVariable String backId) {
        List<HisOrderBackfeeItem> hisOrderBackfeeItems = returnPremiumService.queryOrderBackfeeItemByBackId(backId);
        if (hisOrderBackfeeItems == null){
            return new R<>(500,"查询失败",null);
        }
        return new R<>(200,"查询成功",hisOrderBackfeeItems );
    }
    //    订单退款
    @PostMapping("/back/{chId}")
    public R<HisOrderCharge> back(@PathVariable String chId) {
        return returnPremiumService.back(chId);
    }

}
